package movieGandalf.dataObjects;

import java.math.BigInteger;
import java.sql.Connection;
import java.util.List;

import movieGandalf.database.MovieTools;
import movieGandalf.logicGuiConnection.*;

public class DirectorImp implements Director{
	
	private BigInteger id;
	private String name;
	private String imdbName;
	
	/*constructor*/
	
	public DirectorImp(BigInteger id, String name, String imdbName){
		this.id = id;
		this.name = name;
		this.imdbName = imdbName;
	}
	
	
	/*getters*/
	
	public BigInteger getID(){
		return id;
	}
	
	public String getName(){
		return name;
	}
	
	public String getImdbName() {
		return imdbName;
	}
	
	public List<Movie> getRecord(){
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return null;
		
		return MovieTools.getRecord(conn, this.getID());
	}
	
	public List<BigInteger> getRecordIDs() {
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return null;
		
		return MovieTools.getRecordIDs(conn, this.getID());
	}
	
	/*setters*/
	
	public void setID(BigInteger id){
		this.id = id;
	}
	
	public void setName(String name){
		this.name = name;
	}

	public boolean update() {
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return false;
		
		return MovieTools.updateDirector(conn, this);
	}
	
	public boolean delete() {
		Connection conn = MovieTools.getConn();
		if (conn==null)
			return false;
		
		return MovieTools.deleteObject(conn,this);
	}
}
